#ifndef PUBMEDGENOMELOCALDATABASEINTERFACE_H
#define PUBMEDGENOMELOCALDATABASEINTERFACE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QSqlRecord>
#include  <QStringList>
#include <QDir>

#include "../BaseDataManagement/genomedatabaseinterface.h"
#include "pubmedgenomeelementdatapacket.h"
#include "../../../sagevis.h"

class PubMedGenomeLocalDatabaseInterface : public GenomeDatabaseInterface
{
    Q_OBJECT

public:
    explicit PubMedGenomeLocalDatabaseInterface(QObject *parent = 0);
    explicit PubMedGenomeLocalDatabaseInterface(QString dbName, QObject* parent = 0);

    //Note- because these functions are virtual, must recieve generic data packets and convert
    void addGenomeElement( GenomeElementDataPacket* dataPacket );
    void addGenomeElementThenDeleteIt( GenomeElementDataPacket* dataPacket );

    virtual void batchAdd( QList< QPointer<GenomeElementDataPacket> > dataPackets );
    virtual void batchAddThenDelete( QList< QPointer<GenomeElementDataPacket> > dataPackets  );

    virtual void addContig( QPointer< ContigDataPacket> dataPacket  );
    virtual void addContigThenDeleteIt( QPointer< ContigDataPacket> dataPacket  );

    virtual void batchAdd( QList< QPointer< ContigDataPacket> > dataPackets );
    virtual void batchAddThenDelete(QList< QPointer< ContigDataPacket> > dataPackets  );

    void empty();

    virtual void beginTransaction();
    virtual void commitTransaction();

//    QList< QPointer<ContigDataPacket> > getSortedByLength(bool longToShort);
//    void fillContigWithDataPackets( ContigDataPacket* cdp);

    void getSortedByLength( QList< QPointer<ContigDataPacket> >&, QList< QPointer<GenomeElementDataPacket> >&, bool );
    void getContigsWithCluster( QString clusterId, QList< QPointer<ContigDataPacket> >&, QList< QPointer<GenomeElementDataPacket> >& );
    void getStringMatches( QString searchFragment, QList< QPointer<ContigDataPacket> >&, QList< QPointer<GenomeElementDataPacket> >& );

protected:
    bool createDatabase();
    bool createDatabase( QString dbName );

    int count = 0;
    int failedCount = 0;
    int succeededCount = 0;

    int contigCount = 0;
    int contigFailedCount = 0;
    int contigSucceededCount = 0;

    int numToDisplay;
};

#endif // PUBMEDGENOMELOCALDATABASEINTERFACE_H
